import 'CardPermissonDto.dart';

/// WriteoffUserUpdateDto
class WriteoffUserUpdateDto {
  /// 用户ID
  final int userId;

  /// 用户名
  final String userName;

  /// 邮箱
  final String email;

  /// 卡种类与卡分类信息
  final List<CardPermissonDto> cardPermissonList;

  /// 核销客服的报价权限，1-有，0-无
  final int? quotePermission;

  WriteoffUserUpdateDto({
    required this.userId,
    required this.userName,
    required this.email,
    required this.cardPermissonList,
    this.quotePermission,
  });

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['userId'] = userId;
    data['userName'] = userName;
    data['email'] = email;
    data['cardPermissonList'] = cardPermissonList
        .map((e) => e.toJson())
        .toList();
    if (quotePermission != null) data['quotePermission'] = quotePermission;
    return data;
  }

  factory WriteoffUserUpdateDto.fromJson(Map<String, dynamic> json) {
    return WriteoffUserUpdateDto(
      userId: json['userId'],
      userName: json['userName'],
      email: json['email'],
      cardPermissonList: json['cardPermissonList'] != null
          ? List<CardPermissonDto>.from(
              json['cardPermissonList'].map(
                (x) => CardPermissonDto.fromJson(x),
              ),
            )
          : [],
      quotePermission: json['quotePermission'],
    );
  }
}
